//
//  HGDividendDetailCell.m
//  RedWinMall
//
//  Created by HeDianZhao on 2018/8/8.
//  Copyright © 2018年 HeDianZhao. All rights reserved.
//

#import "HGDividendDetailCell.h"
#import "HGFansModel.h"

@implementation HGDividendDetailCell {
    NSMutableArray <UILabel *> *labels;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubViews];
    }
    return self;
}

- (void)setModel:(HGFansModel *)model {
    _model = model;
    
    NSString *no = [NSString stringWithFormat:@"订单编号:%@",model.orderNo];
    NSString *moeny = [NSString stringWithFormat:@"交易金额:%@",model.moneyText];
    NSString *date = [NSString stringWithFormat:@"交易时间:%@",model.date];
    NSString *gary = [NSString stringWithFormat:@"灰:%@",model.greyScoreText];
    NSString *red = [NSString stringWithFormat:@"红:%@",model.redScoreText];
    
    NSArray *data = @[no,moeny,date,gary,red];
    
    [labels enumerateObjectsUsingBlock:^(UILabel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.text = data[idx];
    }];
}


- (void)initSubViews {
    
    CGFloat margin = 14;
    
    self.selectionStyle = UITableViewCellSeparatorStyleNone;
 
    labels = [@[] mutableCopy];
    NSArray *leftTiele = @[@"订单编号:",@"交易金额:",@"交易时间:",@"灰:",@"红:"];
    for (int i = 0; i < leftTiele.count; i++) {
        UILabel *label = [[UILabel alloc] init];
        label.text = leftTiele[i];
        label.textColor = kColorDefult;
        label.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:label];
        
        if (i > 2) {
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.contentView).multipliedBy(i == 3 ? 0.8 : 1.2);
                make.width.offset(kScreenWidth/4);
                make.right.offset(-margin);
            }];
            [labels addObject:label];
            continue;
        }
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(margin + i * 20);
            make.left.offset(margin);
        }];
        
        [labels addObject:label];
    }
    
    
}

@end
